package com.ihr360.oneclick.dto.spreadsheet;

import com.ihr360.commons.model.entity.StringIdWithTime;
import com.ihr360.hibernate.type.json.JsonStringType;
import com.ihr360.oneclick.entity.RowHeaderColumn;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.List;

/**
 * 电子表格 表头信息
 */
@Table(name = "tab_spreadsheet_row_header")
@Entity
@DynamicUpdate
@TypeDefs({
        @TypeDef(name = "json" , typeClass = JsonStringType.class)
})
public class SpreadSheetRowHeaderDto extends StringIdWithTime {
    @Column(length = 40, nullable = false)
    private String spreadsheetId;

    /**
     * blob，二进制形式的长文本数据,BLOB类型 最大65535=64k
     * 这里面放了行的表头信息
     * TODO list<实体> 数据类型，名称
     */
    @Type(type = "json")
    @Column(columnDefinition = "text")
    private List<RowHeaderColumn> data;

    /**
     * data 信息摘要（MD5）
     */
    @Column(length = 64)
    private String md5Sum;

    public SpreadSheetRowHeaderDto() {

    }

    /*public SpreadSheetRowHeaderDto(String spreadsheetId, byte[] data) {
        this.spreadsheetId = spreadsheetId;
        this.data = data;
    }*/
    public SpreadSheetRowHeaderDto(String spreadsheetId, List<RowHeaderColumn> data) {
        this.spreadsheetId = spreadsheetId;
        this.data = data;
    }

    public String getSpreadsheetId() {
        return spreadsheetId;
    }

    public void setSpreadsheetId(String spreadsheetId) {
        this.spreadsheetId = spreadsheetId;
    }

    public List<RowHeaderColumn> getData() {
        return data;
    }

    public void setData(List<RowHeaderColumn> data) {
        this.data = data;
    }
    /*    public byte[] getData() {
        return data;
    }

    public void setData(byte[] data) {
        this.data = data;
    }

    public String getDataStr() {
        return new String(data, StandardCharsets.UTF_8);
    }

    public void setDataStr(String data) {
        this.data = data.getBytes();
    }*/

    public String getMd5Sum() {
        return md5Sum;
    }

    public void setMd5Sum(String md5Sum) {
        this.md5Sum = md5Sum;
    }
}